package com.linsir.ext.beetl;

import org.beetl.core.Context;
import org.beetl.core.Function;

import com.alibaba.fastjson.JSONObject;
/**
 * @author linsir
 * @title: ParseJson
 * @projectName linsir-mu
 * @description: TODO
 * @date 2021/12/3 23:07
 */
public class ParseJson implements Function{
        @Override
        public Object call(Object[] paras, Context ctx) {
                if (paras.length != 1) {
                        throw new RuntimeException("参数错误，请传入一个JSON字符串");
                }
                Object para = paras[0];
                if (para == null) {
                        return null;
                }
                return JSONObject.parse(para.toString());
        }
}
